var app = new Vue({
  el: '#main',
  data: {
    query: '',//ipt输入音乐名称
    musicList: [],//音乐素组
    musicSrc: '',//音乐地址
    musicImg: '',//音乐图片
    hotComments: [],//热评数组
    isPlay: false,//判断动画
    name: '',//歌手名字
    musicname: '',//歌曲名字
    mvSrc: '',
    isShow: false,//显示
  },
  methods: {
    //搜索歌曲
    searchMusic: function () {
      var that = this
      axios.get('https://autumnfish.cn/search?keywords=' + this.query)
        .then(function (res) {
          console.log(res);
          that.musicList = res.data.result.songs
        })
    },
    //播放歌曲
    playMusic: function (id) {
      var that = this
      //歌曲地址
      axios.get('https://autumnfish.cn/song/url?id=' + id)
        .then(function (res) {
          that.musicSrc = res.data.data[0].url
        })
      //歌曲详情
      axios.get('https://autumnfish.cn/song/detail?ids=' + id)
        .then(function (res) {
          that.musicImg = res.data.songs[0].al.picUrl
          that.musicname = res.data.songs[0].name
          that.name = res.data.songs[0].ar[0].name
        })
      //歌曲评论
      axios.get('https://autumnfish.cn/comment/hot?type=0&id=' + id)
        .then(function (res) {
          that.hotComments = res.data.hotComments
        })

    },
    //播放动画
    play: function () {
      this.isPlay = true
    },
    //暂停动画
    pause: function () {
      this.isPlay = false
    },
    //歌曲mv
    playmv: function (id) {
      var that = this
      axios.get('https://autumnfish.cn/mv/url?id=' + id)
        .then(function (res) {
          that.mvSrc = res.data.data.url
          that.isShow = true
          that.musicSrc = ''
        })
    },
    //点击消除mv
    clickbox: function () {
      this.isShow = false
      this.mvSrc = ''
    },
  },
})
